import { toLower } from 'lodash';
import WxPay from 'wechatpay-node-v3'; // 支持使用require
import fs from 'fs';
import request from 'superagent';

/*
const pay = new WxPay({
  appid: 'wx254b44aaf45b9c6e',
  mchid: '1678426028',
  publicKey: fs.readFileSync('./wxpay-cert/lkhg/apiclient_cert.pem'), // 公钥
  privateKey: fs.readFileSync('./wxpay-cert/lkhg/apiclient_key.pem'), // 秘钥
});
*/
// 酒店获取证书给我们放到服务器上
export const getWxPay = (hotel) => {
  return new WxPay({
    appid: hotel.appid,
    mchid: hotel.mchid,
    publicKey: fs.readFileSync(`./wxpay-cert/${toLower(hotel.code)}/apiclient_cert.pem`), // 公钥
    privateKey: fs.readFileSync(`./wxpay-cert/${toLower(hotel.code)}/apiclient_key.pem`), // 秘钥
  });
}

export async function getPrepayId() {

}